package vip.xiaonuo.smzq.modular.psba.service.impl;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import vip.xiaonuo.smzq.modular.psba.entity.PsbaGtBg;
import vip.xiaonuo.smzq.modular.psba.entity.vo.PsbaGtBgDetailVO;
import vip.xiaonuo.smzq.modular.psba.mapper.PsbaGtBgMapper;
import vip.xiaonuo.smzq.modular.psba.service.IPsbaGtBgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vip.xiaonuo.common.page.CommonPageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * 评审备案报告情况 服务实现类
 *
 * @author Kevin
 * @since 2024-05-15
 */
@Service
public class PsbaGtBgServiceImpl extends ServiceImpl<PsbaGtBgMapper, PsbaGtBg> implements IPsbaGtBgService {

    @Resource
    private PsbaGtBgMapper psbaGtBgMapper;

    @Override
    public Page<PsbaGtBg> page(long current,long size) {


        Page<PsbaGtBg> page = new Page<>(current, size);
        QueryWrapper<PsbaGtBg> queryWrapper = new QueryWrapper<>();
        return this.page( psbaGtBgMapper.selectPage(page, queryWrapper));
    }

    /**
     * 评审备案报告详情
     *
     * @param psbabh
     * @return
     */
    @Override
    public PsbaGtBgDetailVO detail(String psbabh) {
        PsbaGtBgDetailVO vo = new PsbaGtBgDetailVO();
        List<PsbaGtBgDetailVO> list = psbaGtBgMapper.getDetail(psbabh);
        if (CollectionUtils.isNotEmpty(list)) {
            vo = list.get(0);
        }
        return vo;
    }

    @Override
    public PsbaGtBg getPsbaGtBg(String psbabh) {
        try{
            QueryWrapper<PsbaGtBg> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("psbabh",psbabh);
            queryWrapper.orderByDesc("bgtjrq");
            List<PsbaGtBg> list = psbaGtBgMapper.selectList(queryWrapper);
            if(list!=null&&list.size()>0){
                return list.get(0);
            }
        }catch (Exception e){

        }

        return null;
    }
}
